package cn.alm.allinoneboot.controller;

import cn.alm.allinoneboot.common.CommonResult;
import cn.alm.allinoneboot.dto.CommonDto;
import cn.alm.allinoneboot.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@CrossOrigin
public class UserController {

    @Resource
    UserService userService;

    @PostMapping("user/getUserByUsername")
    public CommonResult getUserByUsername(@RequestBody CommonDto dto) {
        return userService.getUserByUsername(dto.getUsername());
    }

    @PostMapping("user/login")
    public CommonResult login(@RequestBody CommonDto dto) throws Exception {
        return userService.login(dto);
    }

    @PostMapping("user/createUser")
    public CommonResult createUser(@RequestBody CommonDto dto) throws Exception {
        return userService.createUser(dto);
    }

    @PostMapping("user/logout")
    public CommonResult logout(@RequestBody CommonDto dto) {
        return userService.logout(dto);
    }

}
